﻿using System;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

namespace FatFreeFitness._secured.management
{
    public partial class ManageRoutines : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
        {
            RadGrid1.DataBind();
        }

        protected void FormView2_ItemInserting(object sender, FormViewInsertEventArgs e)
        {
            int routineID = Int32.Parse(((sender as FormView).Parent.FindControl("hidResourceID") as HiddenField).Value);
            e.Values.Add("RoutineID", routineID);
        }

        protected void FormView2_ItemInserted(object sender, FormViewInsertedEventArgs e)
        {
            var formview2 = (sender as FormView);
            var radgrid2 = formview2.Parent.FindControl("RadGrid2") as RadGrid;
            formview2.DataBind();
            radgrid2.DataBind();
        }

        protected void FormView2_ModeChanging(object sender, FormViewModeEventArgs e)
        {
            // no op
        }
        protected void RadGrid2_ItemDeleted(object sender, Telerik.Web.UI.GridDeletedEventArgs e)
        {
            ((sender as RadGrid).Parent.FindControl("FormView2") as FormView).DataBind();
        }
    }
}